home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / getent < prev    next >
Encoding:
Text File  |  2010-11-16  |  1.3 KB  |  56 lines

  1. # bash completion for getent
  2.  
  3. have getent &&
  4. _getent()
  5. {
  6.     local cur prev
  7.  
  8.     COMPREPLY=()
  9.     _get_comp_words_by_ref cur prev
  10.  
  11.     case $prev in
  12.         passwd)
  13.             COMPREPLY=( $( compgen -u "$cur"  ) )
  14.             return 0
  15.             ;;
  16.         group)
  17.             COMPREPLY=( $( compgen -g "$cur"  ) )
  18.             return 0
  19.             ;;
  20.         services)
  21.             COMPREPLY=( $( compgen -s "$cur"  ) )
  22.             return 0
  23.             ;;
  24.         hosts)
  25.             COMPREPLY=( $( compgen -A hostname "$cur"  ) )
  26.             return 0
  27.             ;;
  28.         protocols|networks|ahosts|ahostsv4|ahostsv6|rpc)
  29.             COMPREPLY=( $( compgen -W "$( getent "$prev" | \
  30.                 awk '{ print $1 }' )" -- "$cur" ) )
  31.             return 0
  32.             ;;
  33.         aliases|shadow)
  34.             COMPREPLY=( $( compgen -W "$( getent "$prev" | cut -d: -f1 )" \
  35.                 -- "$cur" ) )
  36.             return 0
  37.             ;;
  38.     esac
  39.  
  40.  
  41.     if [ $COMP_CWORD -eq 1 ]; then
  42.         COMPREPLY=( $( compgen -W 'passwd group hosts services protocols \
  43.             networks ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc \
  44.             shadow' -- "$cur" ) )
  45.     fi
  46. } &&
  47. complete -F _getent getent
  48.  
  49. # Local variables:
  50. # mode: shell-script
  51. # sh-basic-offset: 4
  52. # sh-indent-comment: t
  53. # indent-tabs-mode: nil
  54. # End:
  55. # ex: ts=4 sw=4 et filetype=sh
  56.